package com.CustomClasses;

import com.facebook.Request;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.model.GraphUser;

public class FacebookUser{
	
	private static String user_ID;
	
	
	private static void excuteRequest(){
		
		Session session = Session.getActiveSession();
		   if (session != null && session.isOpened()) {
		        // If the session is open, make an API call to get user data
		        // and define a new callback to handle the response
		        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
		            @Override
		            public void onCompleted(GraphUser user, Response response) {
		                // If the response is successful

		                    if (user != null) {
		                        user_ID = user.getId();//user id
		                    }   
		                   
		            }   
		        }); 
		        
		    
					Request.executeBatchAsync(request);
				
		   }

	}
	public static int getId(){
		excuteRequest();
		
		return Integer.valueOf(user_ID);

	}

}
